package com.dindang.maintenance.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.maintenance.di.component.DaggerPlanComponent;
import com.dindang.maintenance.di.module.PlanModule;
import com.dindang.maintenance.mvp.contract.PlanContract;
import com.dindang.maintenance.mvp.presenter.PlanPresenter;

import com.dindang.maintenance.R;


import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/maintenance/activity/PlanActivity")
public class PlanActivity extends BaseActivity<PlanPresenter> implements PlanContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    EditText mEtCompletionValue;
    EditText mEtPriceValue;
    TextView mTvCommit;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerPlanComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .planModule(new PlanModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.maintenance_activity_plan; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.maintenance_iv_back);
        mTvTitle = findViewById(R.id.maintenance_tv_title);
        mEtCompletionValue = findViewById(R.id.maintenance_et_completion_value);
        mEtPriceValue = findViewById(R.id.maintenance_et_price_value);
        mTvCommit = findViewById(R.id.maintenance_tv_commit);

        mTvTitle.setText("完成");
        mTvTitle.setOnClickListener(v -> finish());
        mIvBack.setOnClickListener(v -> finish());

        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public EditText getEtCompletionValue() {
        return mEtCompletionValue;
    }

    @Override
    public EditText getEtPriceValue() {
        return mEtPriceValue;
    }

    @Override
    public TextView getTvCommit() {
        return mTvCommit;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }
}
